<head>
	<script type="text/javascript" src="<?php echo base_url(); ?>js/basic.js"></script>
</head>
<div id="content" class="testd"><br>
<h1><?php if($title){ echo $title; } ?></h1><br>
<a href="<?php echo site_url('quiz');?>">Back </a>
<?php 
if($resultstatus){ echo "<div id='result' style='text-align:center ;'><font color='#fff' size='4'>".$resultstatus."</font></div>"; }
 ?>
 <div class="wite">
<form method="post" action="<?php echo site_url('quiz/edit_quiz/'.$result->quid);?>">
<table id="formdata">
<tr>
	<td>Quiz Name</td>
	<td><input type='text' name='quiz_name' value="<?php echo $result->quiz_name;?>"></td>
</tr>	
<tr>
	<td valign="top">Quiz Description</td>
	<td valign="top">
	<textarea name="description"><?php echo $result->description;?></textarea> 
	</td>
</tr>
<tr>
	<td>Quiz Time Duration</td>
	<td><input type='text' name='quiz_time_duration' value="<?php echo $result->duration;?>">Minutes</td>
</tr>
<tr>
	<td>Start Time</td>
	<td><input type='text' name='test_start_time' value="<?php echo date('Y/m/d',$result->start_time);?>"> ( format YYYY/MM/DD HH:MM:SS  )</td>
</tr>	
<tr>
	<td>End Time</td>
	<td><input type='text' name='test_end_time'  value="<?php echo date('Y/m/d',$result->end_time);?>"> ( eg. 2014/10/31 23:59:59 )</td>
</tr>	

<tr>
	<td>Percentage required to pass</td>
	<td>
		<select name="pass_percentage">
			<?php for($i = 0;$i <= 100;$i++){ ?>
				<option value="<?php echo $i;  ?>" <?php if($result->pass_percentage == $i){ echo "selected";}?> ><?php echo $i;  ?></option>
			<?php } ?>
		</select>%
	</td>
</tr>	
<tr>
	<td valign="top">Assign to Groups</td>
	<td>
		<?php
		$group_counter = 1; 
		foreach($groups as $key => $group){ ?>
			<?php echo $group['group_name']; ?><input type="checkbox" name="assigned_groups[]" value="<?php echo $group['gid']; ?>" <?php if(in_array($group['gid'],$assigned_gids)){ echo "checked";} ?> > &nbsp;&nbsp;
		<?php if($group_counter%5 == 0){ echo "</br>"; } $group_counter++; }  ?>
	</td>
</tr>	
<tr>
	<td>Test type</td>
	<td>
		<input type='radio' name='test_type' value='0' <?php if($result->test_type == "0"){ echo "checked";}?> >Free
		<input type='radio' name='test_type' value='1'  <?php if($result->test_type == "1"){ echo "checked";}?> >Paid &nbsp; 
		( Credit <input type="text" name="test_charges" value="<?php echo $result->credit;?>"> )
	</td>
</tr>	
<tr>
	<td>Allow to View Answer</td>
	<td>
		<input type='radio' name='view_answer' value='1'  <?php if($result->view_answer == "1"){ echo "checked";}?> >Yes
		<input type='radio' name='view_answer' value='0'  <?php if($result->view_answer == "0"){ echo "checked";}?>>No 
	</td>
</tr>	
<tr>
	<td>Maximum Attempts</td>
	<td>
		<select name="max_attemp">
			<?php for($i = 1;$i <= 1000;$i++){ ?>
				<option value="<?php echo $i;  ?>" <?php if($result->max_attempts == $i){ echo "selected";}?>><?php echo $i;  ?></option>
			<?php } ?>
		</select>
	</td>
</tr>	
<tr>
	<td>Correct answer score</td>
	<td><input type='text' name='correct_answer_score' value="1" value="<?php echo $result->correct_score;?>"></td>
</tr>	
<tr>
	<td>Incorrect answer score</td>
	<td><input type='text' name='incorrect_answer_score' value="0" value="<?php echo $result->incorrect_score;?>"></td>
</tr>	

</table>

<br>
Add questions
<table id="formdata">
<?php
foreach($assigned_questions as $key => $val){
?>
<tr>
<td valign="top">Select Category</td><td valign="top">
	<select name="cid[]" >
	<option value="0">Select</option>
	<?php foreach($category as $value){ ?>
	<option value="<?php echo $value->cid; ?>" <?php if($val['cid']==$value->cid ){ echo "selected"; } ?> ><?php echo $value->category_name; ?></option>
	<?php } ?></select> </td>
<td valign="top">Select Difficult Level</td><td valign="top">
<select name="did[]" >
<option value="0">Select</option>
	<?php foreach($difficult_level as $value){ ?>
<option value="<?php echo $value->did; ?>"  <?php if($val['did']==$value->did ){ echo "selected"; } ?> ><?php echo $value->level_name; ?></option>
<?php } ?></select>  </td>
	<td>No. of Ques to add in test</td>
	<td>
	<select name="no_of_questions[]">
	<option value="0" >0</option>
	<option value="<?php echo $val['no_of_questions']; ?>" selected ><?php echo $val['no_of_questions']; ?></option>
	</select>	
	</td>
</tr>
<?php
}
?>
<tr>
<td valign="top">Select Category</td><td valign="top">
	<select name="cid[]" id='cid'>
	<option value="0">Select</option>
	<?php foreach($category as $value){ ?>
	<option value="<?php echo $value->cid; ?>"><?php echo $value->category_name; ?></option>
	<?php } ?></select> </td>
<td valign="top">Select Difficult Level</td><td valign="top">
<select name="did[]" id='did'>
<option value="0">Select</option>
	<?php foreach($difficult_level as $value){ ?>
<option value="<?php echo $value->did; ?>"><?php echo $value->level_name; ?></option>
<?php } ?></select>  </td>
	<td>No. of Ques to add in test</td>
	<td id="no_of_question">
		
	</td>
</tr>
</table>
<br>
<table id="formdata">
<tr>
<td valign="top"></td>
<td valign="top">
<input type="submit" value="Submit Quiz" name="submit_quiz"> </td></tr>
</form>
</table>

</div>
</div>

<script type="text/javascript">
	tinyMCE.init({
	
    mode : "textareas",
		theme : "advanced",
		relative_urls:"false",
	 plugins: "jbimages",
	
  // ===========================================
  // PUT PLUGIN'S BUTTON on the toolbar
  // ===========================================
	
 
	
		theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect",
		theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
		theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
		theme_advanced_buttons4 : "jbimages,insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak,restoredraft,visualblocks",
		
		
	});
</script>
